#!/usr/bin/python3.8
# -*- coding: utf-8 -*-
# @Time    : 2021/5/14 上午11:25
# @Author  : yinrong
# @Email   : yfyinrong@shwpg.com
# @File    : mqttData.py
# @Software: PyCharm
import datetime
import time
import random

from RootPath import RootPath
import os
from common.YmlUtil import YmlUtil
from common.KafkaUtil import KafkaProduce
from common.contactStr import mqttMessageContact, sqlContact

path = os.path.join(RootPath.getRootPath(), "Application.yml")

#获取当地时间
nowtime=datetime.datetime.now()
#格式化时间
strtime=nowtime.strftime("%Y-%m-%d %H:%M:%S")

def kaf():
    # 获取当地时间
    nowtime = datetime.datetime.now()
    # 格式化时间
    strtime = nowtime.strftime("%Y-%m-%d %H:%M:%S")
    # kafkadata={
    #     "deviceId": "2022051312",
    #     "timestamp": strtime,
    #     "values": {
    #         "jsc_COD":31
    #     },
    #     "ratioValues": {
    #         "jsc_COD":31
    #     }
    # }
    kafkadata = {
        "deviceId": "SSBF0001",
        "timestamp": strtime,
        "values": {
            "No1OP_CggxAlarm": 1
        },
        "ratioValues": {
            "No1OP_CggxAlarm": 1
        }
    }

    # kafkadata = mqttMessageContact(deviceID, point_value)
    print(kafkadata)
    # #测试环境topic
    # KafkaProduce("TEST_DEVICE_DATA", kafkadata)
    # #演示环境topic
    # KafkaProduce("SHOW_DEVICE_DATA", kafkadata)
    #泰安环境topic
    KafkaProduce("RELEASE_DEVICE_DATA", kafkadata)

if __name__ == '__main__':
    kaf()
